package com.xbongbong.schedule.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * 延时任务类型
 *
 * @author haibin.zhang
 * @version v1.0
 * @date 2019/2/26 10:19
 * @since v1.0
 */
@Getter
public enum ScheduleTaskTypeEnum {

    /**
     * 阶段超时提醒
     */
    STAGE_TIMEOUT_REMIND(1, "阶段超时提醒"),
    /**
     * sla日志定时关闭
     */
    SLA_LOG(2,"sla日志定时关闭"),
    /**
     * 自定义工单工作流
     */
    WORK_ORDER_V2_WORKFLOW(3,"自定义工单工作流"),
    ;

    private Integer code;
    private String memo;

    ScheduleTaskTypeEnum(Integer code, String memo) {
        this.code = code;
        this.memo = memo;
    }

    public static ScheduleTaskTypeEnum getByType(Integer type) {
        for (ScheduleTaskTypeEnum anEnum : ScheduleTaskTypeEnum.values()) {
            if (Objects.equals(anEnum.getCode(), type)) {
                return anEnum;
            }
        }
        return null;
    }

    public static String getMemoByType(Integer type) {
        ScheduleTaskTypeEnum scheduleTaskTypeEnum = getByType(type);
        if (Objects.nonNull(scheduleTaskTypeEnum)) {
            return scheduleTaskTypeEnum.getMemo();
        }
        return "";
    }
}
